#pragma once
#include "../zhelpers.h"
#include <map>
#include <string>
#include "thread.h"
#include "data.h"

using std::string;
using std::vector;

class server{
	string _name;
	string _ip;
	int _port;

	void *_zmq;
	void *_zmq_front;
	void *_zmq_back;

//	database_bdb *_db;
	thread_pool *_thread_pool;

	public:
	server(){_zmq = NULL;_zmq_front = NULL;_zmq_front = NULL;_thread_pool = NULL;}
	server(string name,string ip,int port){
		_name = name;_ip = ip;_port = port;
		_zmq = NULL;_zmq_front = NULL;_zmq_front = NULL;
		_thread_pool = NULL;
	}

	server &operator=(const server &s){_name = s._name;_ip = s._ip;_port = s._port;_zmq = NULL;_zmq_front = NULL;_zmq_front = NULL;_thread_pool = NULL;}

	virtual ~server(){};//delete thread_pool, destroy zmq
	void set_name(string name){_name = name;}
	void set_ip(string ip){ _ip = ip;}
	void set_port(int port){ _port = port;}
	string get_name(){return _name;}

	void set_zmq(void *p){ _zmq = p;}
	void set_zmq_front(void *p){ _zmq_front = p;}
	void set_zmq_back(void *p){ _zmq_back = p;}
	
	void *get_zmq(){return _zmq;}
	void *get_zmq_front(){return _zmq_front;}
	void *get_zmq_back(){return _zmq_back;}
	
//	database *get_data_base(){return _db;}
	
	void set_thread_pool(thread_pool *tp){_thread_pool = tp;}
	thread_pool *get_thread_pool(){return _thread_pool;}
	
	int start();
};


class match_server : public server
{
	server *_extract_server;
	database_bdb *_db;

	public:
	match_server(){_extract_server = NULL;_db = NULL;}

	void add_extract_server(server *s){_extract_server = s;}
	server *get_extract_server(){return _extract_server;}

	void set_database(database_bdb *db){_db = db;}
	database_bdb *get_database(){return _db;}
};










